package Leo.serviceProviders.config;

import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status;
import org.springframework.stereotype.Component;

/**
 * 自定义健康监视器，用于判断自身是否可以正常运作（可以通过代码，验证包括自身运作时依赖的其他服务器是否ok）
 */
@Component
public class HealthIndicatorImpl implements HealthIndicator {
    private boolean healthFlag = true;
    public Health health() {
        if(healthFlag){
            return new Health.Builder(Status.UP).build();
        }else{
            return new Health.Builder(Status.DOWN).build();
        }
    }

    public boolean isHealthFlag() {
        return healthFlag;
    }

    public void setHealthFlag(boolean healthFlag) {
        this.healthFlag = healthFlag;
    }
}
